import time

from common.base import Base, By


class LoginEcshop(Base):
    # 找到用户框输入
    def ipt_username(self, locator, username):
        # 调用父类的发送方法
        self.send_key(locator, username)

    # 找到密码输入框
    def ipt_password(self, locator, password):
        # 调用父类的发送方法
        self.send_key(locator, password)

    # 点击保持登录状态
    def click_keep(self, locator):
        # 调用父类的点击方法
        self.click(locator)

    # 点击登录按钮
    def click_login(self, locator):
        # 调用父类的点击方法
        self.click(locator)


if __name__ == '__main__':
    ecshop = LoginEcshop('chrome')
    ecshop.get('https://ecshop.test2.shopex123.com/user.php')
    ecshop.ipt_username((By.NAME, 'username'), 'fine1')
    ecshop.ipt_password((By.NAME, 'password'), '123456')
    ecshop.click_keep((By.NAME, 'remember'))
    time.sleep(2)
    ecshop.click_login((By.CLASS_NAME, 'loginbtn'))
    time.sleep(2)
    ecshop.quit()
